
/*
This source code is licensed under the terms of the
GNU Affero General Public License found in the LICENSE file in
the root directory of this source tree.

Copyright (c) 2021-present Kaleidos INC
*/

:host {
  --menu-margin: 12px;
  --menu-margin-text: 12px;

  background-color: var(--color-black800);
  display: flex;
  flex-direction: column;
  height: 100%;
  left: 0;
  position: relative;
  top: 0;
}

.nav-wrapper {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

.nav-inner {
  display: flex;
  flex: 1;
  flex-direction: column;
  height: 100%;
  width: 200px;
}

:host(.collapsed) {
  width: 48px;

  & .scrum .child-menu {
    display: none;
  }
}

h1 {
  background-color: var(--color-black900);
  margin: 0;
  padding: var(--spacing-2);
  padding-left: var(--menu-margin);

  & .project-link {
    align-items: center;
    color: var(--color-solid-primary);
    display: flex;
    font-size: var(--font-size-medium);
    text-decoration: none;

    /* two lines ellipsis */
    & .project-name {
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    &:hover {
      color: var(--color-solid-primary);
    }
  }

  & img {
    border-radius: 2px;
    height: 24px;
    margin-right: var(--menu-margin-text);
    width: 24px;
  }
}

.main-menu {
  margin: 0;
  padding: 0 0 var(--spacing-1) 0;

  & svg {
    fill: var(--color-gray400);
    height: 24px;
    width: 24px;
  }
}

.menu-option {
  list-style: none;
  margin-bottom: var(--spacing-1);

  &.active > a,
  &.active > button,
  &.active-dialog > a,
  &.active-dialog > button,
  & > a:hover,
  & > button:hover {
    background-color: var(--color-black900);
    color: var(--color-white);
    font-weight: var(--font-weight-bold);
  }

  &.active > a,
  &.active > button {
    color: var(--color-gray400);
  }

  & > a:hover > svg,
  & > button:hover > svg {
    fill: var(--color-white);
  }

  &:last-child {
    margin-bottom: 0;
  }

  & a,
  & button {
    align-items: center;
    color: var(--color-gray400);
    display: flex;
    font-size: var(--font-size-medium);
    height: 40px;
    padding: 0;
    text-decoration: none;
    transition: background-color .2s linear;
  }

  & button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding-right: var(--spacing-1);
    width: 100%;
  }

  & svg {
    margin-left:  var(--menu-margin);
    margin-right: var(--menu-margin-text);
  }

  & .agile-chevron {
    fill: var(--color-solid-primary);
    margin: 0 0 0 auto;
    transition: all .2s linear;
    width: 16px;
  }
}

.child-menu {
  background-color: var(--color-black900);
  display: none;
  list-style: none;
  padding: 0 0 var(--spacing-1) 0;

  & .menu-option {
    margin-bottom: 0;
  }

  & .menu-option-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  & a {
    min-width: 0;
    padding-left: var(--spacing-5);
  }

  & a,
  & button {
    &:hover,
    &.active {
      color: var(--color-solid-primary);
      font-weight: var(--font-weight-bold);
    }
  }
}

.scrum {
  &.active {
    & .agile-chevron {
      transform: rotate(90deg);
      transition: transform .2s linear;
    }

    & .child-menu {
      display: block;
    }
  }
}

.menu-secondary {
  border-bottom: 1px solid var(--color-black900);
  border-top: 1px solid var(--color-black900);
  margin-top: auto;
}

.collapse {
  align-items: center;
  appearance: none;
  background: none;
  border: 0;
  color: var(--color-gray400);
  cursor: pointer;
  display: flex;
  font-size: var(--font-size-medium);
  justify-content: flex-end;
  padding: var(--spacing-1);
  width: 100%;

  & svg {
    background: var(--color-black900);
    border-radius: 50%;
    fill: var(--color-link-primary);
    height: 24px;
    margin-left: var(--spacing-1);
    padding: 4px;
    width: 24px;
  }

  &.collapsed {
    justify-content: center;
    transform: rotate(180deg);
    width: 48px;

    & svg {
      margin: 0;
    }
  }

  &:hover {
    color: var(--color-white);
    font-weight: var(--font-weight-bold);

    & svg {
      fill: var(--color-white);
    }
  }
}

.dialog {
  background-color: var(--color-black900);
  display: none;
  position: absolute;
  width: 170px;

  & .menu-option {
    margin-bottom: 0;
  }

  & .child-menu {
    box-shadow: 0px 4px 24px rgba(0, 0, 0, 0.29);
    display: block;
    margin: 0;
    padding: 0;

    & a {
      padding-left: var(--spacing-4);
    }
  }

  &.open {
    display: block;
  }

  & .main-link {
    align-items: center;
    background-color: var(--color-black900);
    color: var(--color-white);
    display: flex;
    padding: 0 var(--spacing-2);

    & .dialog-text {
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      display: -webkit-box;
      font-size: var(--font-size-medium);
      font-weight: var(--font-weight-bold);
      overflow: hidden;
      text-decoration: none;
      text-overflow: ellipsis;
    }
  }

  & a.main-link,
  & button.main-link {
    &:hover {
      color: var(--color-solid-primary);
    }
  }
}
